package com.gugee.common.task.dal.service.impl;

import com.gugee.common.task.dal.service.TaskRecordSvc;
import com.gugee.common.task.dal.mapper.TaskRecordMapper;
import com.gugee.common.task.model.TaskRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: luolifeng
 * Date: 2021-01-26 15:42
 */
@Component
public class TaskRecordSvcImpl implements TaskRecordSvc {
    @Autowired
    TaskRecordMapper taskRecordMapper;
    @Override
    public Optional<TaskRecord> findByTaskType(int taskType) {
        return Optional.ofNullable(taskRecordMapper.findByTaskType(taskType));
    }

    @Override
    public void save(TaskRecord taskRecord) {
        if(taskRecord.getId() == null){
            taskRecordMapper.insert(taskRecord);
        }else{
            taskRecordMapper.updateById(taskRecord);
        }
    }
}
